# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Contributor: Rasmus Thomsen <oss@cogitri.dev>
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Kevin Daudt <kdaudt@alpinelinux.org>
pkgname=colord
pkgver=1.4.6
pkgrel=4
pkgdesc="System daemon for managing color devices"
url="https://www.freedesktop.org/software/colord"
arch="all"
license="GPL-2.0-or-later"
pkgusers="colord"
pkggroups="colord"
depends="libcolord=$pkgver-r$pkgrel"
depends_dev="
	dbus-dev
	dconf-dev
	eudev-dev
	gobject-introspection-dev
	libgudev-dev
	polkit-dev
	sane-dev
	sqlite-dev
	vala
	"
makedepends="$depends_dev
	bash-completion-dev
	lcms2-dev
	libgusb-dev
	meson
	"
install="$pkgname.pre-install $pkgname.pre-upgrade"
subpackages="
	$pkgname-dev
	$pkgname-lang
	$pkgname-colorhug
	$pkgname-sane
	$pkgname-bash-completion
	libcolord
	"
source="https://www.freedesktop.org/software/colord/releases/colord-$pkgver.tar.xz
	disable-udev-hwdb-tests.patch
	"

build() {
	abuild-meson \
		-Dsystemd=false \
		-Dargyllcms_sensor=false \
		-Dman=false \
		-Ddocs=false \
		-Ddaemon_user=colord \
		-Dsane=true \
		-Dvapi=true \
		output .

	meson compile -C output
}

check() {
	# cd-private-test is broken atm
	# meson test

	output/src/cd-self-test
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
	chown -R colord:colord "$pkgdir"/var/lib/colord
}

colorhug() {
	pkgdesc="$pkgdesc (ColorHug support)"

	amove usr/lib/libcolorhug.so.*
	amove usr/lib/girepository-1.0/Colorhug-*.typelib
	amove usr/lib/colord-sensors/libcolord_sensor_colorhug.so
}

sane() {
	pkgdesc="$pkgdesc (SANE support)"
	depends="$pkgname=$pkgver-r$pkgrel"

	amove usr/libexec/colord-sane
	amove usr/lib/colord-plugins/libcolord_sensor_sane.so
}

libcolord() {
	pkgdesc="$pkgdesc (client library)"
	depends=""

	amove usr/lib/libcolord.so.*
	amove usr/lib/libcolordprivate.so.*
	amove usr/lib/girepository-1.0/Colord-*.typelib
}

sha512sums="
d55d3322199d0bfee74eee9e183c9246ec33e755f0144d96087acb3c43ab5a3d872086fcef9f29cdd2295be71daac703cdf90ad10bf183622fdd84347e7af123  colord-1.4.6.tar.xz
4e306254902658ffe0904b4ee3fdc10c473af909662c08fc66b9070fd698e07e1f804e53ccd94160ac57d268269132683808ff8f2bae64fd2a9070d6f024b800  disable-udev-hwdb-tests.patch
"
